package com.huluobo.h3kotlinproject.cart

import android.widget.CheckBox
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.h3kotlinproject.R
import com.huluobo.h3kotlinproject.util.ImageLoader

/**
 *  Created by LC on 2023/10/25.
 */
class CartAdapter(cartList: MutableList<CartBean>) :
    BaseQuickAdapter<CartBean, BaseViewHolder>(R.layout.item_cart, cartList) {
    override fun convert(holder: BaseViewHolder, item: CartBean) {
        //设置图片
        ImageLoader.loadImage(context, item.goods_default_icon, holder.getView(R.id.cart_item_iv_icon))

        holder.setText(R.id.cart_item_tv_name, item.goods_desc)

        holder.setText(R.id.cart_item_tv_price, item.goods_default_price.toString())

        holder.setText(R.id.cart_item_tv_num, item.count.toString())

        //设置是否选中
        holder.getView<CheckBox>(R.id.cart_item_cb).isChecked = item.selected

        //删除按钮是否显示,通过是否选中来控制删除按钮是否显示

    }
}